// 组合继承（伪经典继承）
SuperType.prototype.greet = function () {
    return 'hello~,' + this.card.name;
}

function SuperType(gender) {
    this.card = {
        name: '佩奇',
        age: 20,
        gender: gender
    }
}

// 利用原型链继承
ParentType.prototype = new SuperType();
// 因为ParentType.prototype被重写成为一个实例对象，没有constructor，所以得弥补一个constructor
ParentType.prototype.constructor = ParentType();
ParentType.prototype.sayHobby = function () {
    return 'I like ' + this.hobby;
}

function ParentType(gender, hobby) {
    this.hobby = 'singing';

    // 利用经典继承，借用构造函数
    SuperType.call(this, gender)
}

let child1_type = new ParentType('female')
let child2_type = new ParentType('male')

console.log(child1_type.greet()); //hello~,佩奇
console.log(child1_type.sayHobby()); //I like singing
console.log(child1_type.card); //{ name: '佩奇', age: 20, gender: 'female' }

child2_type.card.name = '黑猫警长';
console.log(child2_type.card); //{ name: '黑猫警长', age: 20, gender: 'male' }
